#include "stuff.h"
#include "Config.h"
#include "State.h"
#include <map>
#include <list>

#ifndef INPUT
#define INPUT

namespace Input
{
	typedef void (*fn)(); 

	std::map<int, fn> binds;
	std::map<int, fn>::iterator iter;

	void (*mouseAction)(int, int);

	void bind(int value, void action())
	{
		binds[value] = action; 
	}

	void unbind(int value)
	{
		binds.erase(value);
	}

	void setMouse(void action(int, int))
	{
		mouseAction = action;
	}

	void update()
	{
		int mousePosX = 0;
		int mousePosY = 0;

		glfwGetMousePos(&mousePosX, &mousePosY);

		mouseAction(mousePosX, mousePosY);

		for(iter = binds.begin(); iter != binds.end(); ++iter)
		{
			if(glfwGetKey(iter->first))
			{
				(iter->second)();
			}
        }
		
		glfwSetMousePos(0, 0);
	}
}

#endif